/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package facade;

import entities.CustomerRequest;
import java.util.Date;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Andrés Felipe
 */
@Stateless
@Remote(CustomerRequestFacadeRemote.class)
public class CustomerRequestFacade extends AbstractFacade<CustomerRequest> implements CustomerRequestFacadeRemote {
    @PersistenceContext(unitName = "Javeriana.EJB.EstimatorPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public CustomerRequestFacade() {
        super(CustomerRequest.class);
    }

    @Override
    public boolean verifyDate(int idRequest) {
        Date now = new Date();
        Date before;
        CustomerRequest request = this.find(idRequest);
        before = request.getCreationdate();
        long time = now.getTime() - before.getTime();
        //System.out.println("timepo de respuesta ------>  " + time);
        long milisecondsTime = 300000;
        if (time > milisecondsTime )
        {
            return false;
        }
        else
        {
            return true;
        }
    }
    
}
